package com.echo.echovividlive.controller;


import com.echo.echovividlive.domain.dto.CommentQueryDTO;
import com.echo.echovividlive.domain.entity.Comment;
import com.echo.echovividlive.domain.entity.Result;
import com.echo.echovividlive.service.ICommentService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiajunjie
 * @since 2024-10-22
 */
@Slf4j
@RestController
@RequestMapping("/echo/comment")
public class CommentController {

    @Resource
    private ICommentService commentService;

    /**
     * 发表评论
     * @param comment
     * @return
     */
    @PostMapping("/post")
    public Result comment(@RequestBody Comment comment) {
        log.info("发表评论参数:{}",comment);
        return commentService.comment(comment);
    }

    /**
     * 查看评论
     * @param commentQueryDTO
     * @return
     */
    @PostMapping("/list")
    public Result commentList(@RequestBody CommentQueryDTO commentQueryDTO) {
        log.info("查看评论参数:{}",commentQueryDTO);
        return commentService.listComment(commentQueryDTO);
    }

    /**
     * 删除评论
     * @param id
     * @return
     */
    @GetMapping("/delete/{id}")
    public Result deleteComment(@PathVariable Integer id) {
        return commentService.deleteCommentById(id);
    }
}
